<template>
  <swiper ref="swiper">
    <!-- <template v-slot:content> -->
      <swiper-item v-for="(item, index) in banners" :key="index">
        <a :href="item.link">
          <img :src="item.image" alt="" @load="imageLoad">
        </a>
      </swiper-item>
    <!-- </template> -->
    
  </swiper>
</template>

<script>
import Swiper from '@/components/common/swipper/Swiper'
import SwiperItem from '@/components/common/swipper/SwiperItem'
export default {
  name: 'IshopHomeswiper',
  components:{
    Swiper,
    SwiperItem
  },
  props: {
    banners:{
      type: Array,
      default: []
    } 
  },
  data() {
    return {
      isLoad: false
    }
  },
  watch:{
    banners: function (newValue) {
      this.$nextTick(function () {
        this.$refs.swiper.domUpdateForData()
      });
      this.isLoad = false
    }
  },
  methods: {
    stopTimer:function(){
      this.$refs.swiper.stopTimer()
    },
    startTimer:function(){
      this.$refs.swiper.startTimer()
    }, 
    imageLoad:function(){
      if(!this.isLoad){
        this.isLoad = true
        this.$emit('swiperImageLoad');
      }
    }
    
  },
};
</script>

<style scoped>

</style>